<template>
    <view class="identificationService">
        <view class="king_til">
            <view class="paiming"><text class="colororg">免费鉴定</text><text class="colororgmini">仅针对VIP客户</text></view>
            <view class="zongjine">
                <view class="jineone">
                    <view>您本月剩余免费鉴定次数<view>{{user_obj.freeIdentifies}}</view>次</view>
                </view>
                <view class="gongxi">
                    <view class="{{user_obj.freeIdentifies>0 ? 'huang' : 'noAllowed'}}" @tap="freePublish">发布鉴定</view>
                </view>

                <!-- <view class="gongxi">
                    <view class="huang" @tap="payPublish">付费发布</view>
                </view> -->
            </view>
        </view>

        <view class="king_til">
            <view class="paiming"><text class="colororg">CDKEY码鉴定</text></view>
            <view class="zongjine zongjinekey">
                <view class="jineone jineonekey">
                    <view class="cdkeytxt">CDKEY码</view>
                    <input class="cdkey" placeholder="请输入CDKEY码" type="text" value="{{key}}" bindinput="changeVal">
                </view>
                <view class="gongxi">
                    <view class="huang" @tap="keyPublish">发布鉴定</view>
                </view>
            </view>
        </view>

        <!-- <view class="king_til">
            <view class="paiming"><text class="colororg">付费鉴定</text></view>
            <view class="zongjine">
                <view class="jineone">
                    <view>鉴定费<view>5</view>元</view>
                </view>
                <view class="gongxi">
                    <view class="huang">发布鉴定</view>
                </view>
            </view>
        </view> -->
        <view class="identificationService_app" @tap="getAllList">
            <view class="identificationService_shuliang">
                <view>集APP已<view>{{idenCount.countUser}}</view>人</view>
                <view>成功鉴定<view>{{idenCount.countGoods}}</view>件</view>
            </view>
            <view class="iconfont_jiantou"><i class="iconfont icon-jiantou"></i></view>
        </view>
    </view>

</template>
<script>
    import wepy from 'wepy';
    import api from '@/api/api';
    import utils from '@/utils/utils';
    import tip from '@/utils/tip';
    import {
        USER_INFO,USER_SPECICAL_INFO,USER_ID
    } from '@/utils/constant';

    export default class ReleaseCompletion extends wepy.page {
        config = {  // 配置当前页面
            navigationBarTitleText: '鉴定服务'   // 头部标题
        }
        components = {

        }

        data = {
            user_obj:{
                freeIdentifies:0
            },
            idenCount:{
                countUser:0,
                countGoods:0
            },
            key:''
        }

        // 获取个人信息
        async user_info() {
            let that = this;
            let user_id = wepy.getStorageSync(USER_ID) || '';
            api.getUserInformation({
              query:{}
            },user_id).then(function(res){
              if(res.data.code == 0){
                that.user_obj = res.data.data;
                that.$apply();
              }else{
                tip.error(res.data.msg)
              }
            })
        }

        // 获取鉴定统计
        async getidentis() {
            let that = this;
            api.countIdentify({
              query:{}
            }).then(function(res){
              if(res.data.code == 0){
                that.idenCount = res.data.data;
                that.$apply();
              }else{
                tip.error(res.data.msg)
              }
            })
        }

        onShow(){
            this.user_info();
            this.getidentis();
            this.key = "";
            this.$apply();
        }

        methods = {  // 方法
            getAllList(){
                wepy.navigateTo({
                    url: '/pages/appraisal/appraisalList?from=service'
                })
            },
            freePublish(){
                if(this.user_obj.freeIdentifies > 0){
                    wepy.navigateTo({
                        url: '/pages/appraisal/freeAppraisal?type=1'
                    })
                }
            },
            keyPublish(){
                let that = this;
                if (!that.key) {
                    return tip.toast("请输入CDKEY码",null,"none");
                }
                api.cdKeyCheck({
                  query:{}
                },that.key).then(function(res){
                  if(res.data.code == 0){
                    wepy.navigateTo({
                        url: '/pages/appraisal/freeAppraisal?type=2&mykey='+that.key
                    })
                  }else{
                    tip.toast(res.data.msg,null,"none")
                  }
                })

            },
            changeVal(e){
                this.key = e.detail.value.trim();
            }
        }
        events = {

        }
    }

</script>
<style lang="less">
    .identificationService{
        .identificationService_image{
            margin-top: 0 !important;
            overflow: hidden;
            text-align: center;
            background: #fff;
            padding: 60rpx 0;
            .identificationService_xinshou{
                float: left;
                width: 50%;
                position: relative;
                image{
                    width:150rpx;
                    height:120rpx;
                }
                .border_right{
                    width: 1rpx;
                    height: 200rpx;
                    background: #ddd;
                    position: absolute;
                    right:0;
                    top: 0;
                }
            }
            .identificationService_gonglue{
                float: left;
                width: 50%;
                image{
                    width:110rpx;
                    height:120rpx;
                }
            }
        }
        >view{
            margin-top: 20rpx;
        }
        .king_til{
            .paiming{
                background: #fff;
                padding: 20rpx;
                border-bottom: 1px solid #ddd;
                border-top: 1px solid #ddd;
                .colororg{
                    border-left: 4px solid orange;
                    padding-left: 20rpx;
                }
                .colororgmini{
                    padding-left: 20rpx;
                    font-size: 25rpx;
                    color: #cccccc;
                }
                .jianshu{
                    font-size: 26rpx;
                    color: #666;
                    padding-left: 20rpx;
                }
            }
            .zongjine{
                background: #fff;
                border-bottom: 1px solid #ddd;
                text-align: center;
                .jineone{
                    padding-top: 60rpx;
                    view{
                        display: inline-block;
                        color: #666;
                        view{
                            color: #ffb025;
                            font-size:50rpx;
                            padding: 0 20rpx;
                        }
                    }
                    .cdkeytxt{
                        display: inline-block;
                        height: 58rpx;
                        width: 140rpx;
                        line-height: 58rpx;
                        left: 5%;
                        position: absolute;
                    }
                    .cdkey{
                        height: 58rpx;
                        width: 450rpx;
                        padding: 0 10rpx;
                        display: inline-block;
                        font-size: 30rpx;
                        left: 200rpx;
                        font-size: 24rpx;
                        position: absolute;
                    }
                }
                .jineonekey{
                    height: 58rpx;
                    padding-top: 0rpx;
                    margin: 0 20rpx;
                    border: solid 1px #cccccc;
                }
                .jinbiImg{
                    padding-top: 40rpx;
                    image{
                        width: 100rpx;
                        height: 100rpx;
                    }
                }
                .gongxi{
                    padding: 40rpx 0;
                    .huang{
                        background: #ffb60b;
                    }
                    .noAllowed{
                        background: #999999;
                    }
                    .lv{
                        background: #7bc162;
                    }
                    >view{
                        width: 40%;
                        margin: 0 auto;
                        height: 70rpx;
                        line-height: 70rpx;
                        color: #fff;
                        border-radius: 10rpx;
                    }

                }
            }
            .zongjinekey{
                padding-top: 40rpx;
                position: relative;
            }
        }
        .identificationService_app{
            background: #fff;
            height: 300rpx;
            position: relative;
            .identificationService_shuliang{
                position: absolute;
                top: 50%;
                left: 50%;
                transform: translate(-50%,-50%);
                view{
                    color: #666;
                    view{
                        display: inline-block;
                        font-size: 50rpx;
                        padding: 0 20rpx;
                        color: #333;
                    }
                }
                view:first-child{
                    padding-bottom: 16rpx;
                }
            }
            .iconfont_jiantou{
                position: absolute;
                right:1%;
                top: 50%;
                transform: translate(-50%,-50%);
                .icon-jiantou{
                    font-size: 40rpx;
                }
            }
        }
    }
</style>
